<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>CUB: cub::BlockHistogram&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38890655-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">CUB
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacecub.html">cub</a></li><li class="navelem"><a class="el" href="classcub_1_1_block_histogram.html">BlockHistogram</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="classcub_1_1_block_histogram-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">cub::BlockHistogram&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt; Class Template Reference<div class="ingroups"><a class="el" href="group___block_module.html">Block-wide</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed description</h2>
<div class="textblock"><h3>template&lt;
    typename T, 
    int BLOCK_THREADS, 
    int ITEMS_PER_THREAD, 
    int BINS, 
    BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt;<br/>
class cub::BlockHistogram&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;</h3>

<p>The <a class="el" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">BlockHistogram</a> class provides <a href="index.html#sec0"><em>collective</em></a> methods for constructing block-wide histograms from data samples partitioned across a CUDA thread block. </p>
<div class="image">
<img src="histogram_logo.png" alt="histogram_logo.png"/>
<div class="caption">
.</div></div>
 <dl class="section user"><dt>Overview</dt><dd>A <a href="http://en.wikipedia.org/wiki/Histogram"><em>histogram</em></a> counts the number of observations that fall into each of the disjoint categories (known as <em>bins</em>).</dd></dl>
<dl class="section user"><dt></dt><dd>Optionally, <a class="el" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">BlockHistogram</a> can be specialized to use different algorithms:<ol type="1">
<li><b><a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2ac14962247ae5693de2de53a8db40ca54">cub::BLOCK_HISTO_SORT</a></b>. Sorting followed by differentiation. <a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2">More...</a></li>
<li><b><a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2abfc89fce43fcda396d18a4b2801025aa">cub::BLOCK_HISTO_ATOMIC</a></b>. Use atomic addition to update byte counts directly. <a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2">More...</a></li>
</ol>
</dd></dl>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td>The sample type being histogrammed (must be castable to an integer bin identifier) </td></tr>
    <tr><td class="paramname">BLOCK_THREADS</td><td>The thread block size in threads </td></tr>
    <tr><td class="paramname">ITEMS_PER_THREAD</td><td>The number of items per thread </td></tr>
    <tr><td class="paramname">BINS</td><td>The number bins within the histogram </td></tr>
    <tr><td class="paramname">ALGORITHM</td><td><b>[optional]</b> <a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2" title="BlockHistogramAlgorithm enumerates alternative algorithms for the parallel construction of block-wide...">cub::BlockHistogramAlgorithm</a> enumerator specifying the underlying algorithm to use (default: <a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2ac14962247ae5693de2de53a8db40ca54">cub::BLOCK_HISTO_SORT</a>)</td></tr>
  </table>
  </dd>
</dl>
<dl class="section user"><dt>A Simple Example</dt><dd>Every thread in the block uses the <a class="el" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">BlockHistogram</a> class by first specializing the <a class="el" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">BlockHistogram</a> type, then instantiating an instance with parameters for communication, and finally invoking collective member functions. </dd></dl>
<dl class="section user"><dt></dt><dd>The code snippet below illustrates a 256-bin histogram of 512 integer samples that are partitioned across 128 threads where each thread owns 4 samples. </dd></dl>
<dl class="section user"><dt></dt><dd><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="cub_8cuh.html">cub/cub.cuh</a>&gt;</span></div>
<div class="line"></div>
<div class="line">__global__ <span class="keywordtype">void</span> ExampleKernel(...)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Specialize a 256-bin BlockHistogram type for 128 threads having 4 character samples each</span></div>
<div class="line">    <span class="keyword">typedef</span> <a class="code" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">cub::BlockHistogram&lt;unsigned char, 128, 4, 256&gt;</a> <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for BlockHistogram</span></div>
<div class="line">    __shared__ <span class="keyword">typename</span> BlockHistogram::TempStorage temp_storage;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for block-wide histogram bin counts</span></div>
<div class="line">    __shared__ <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> smem_histogram[256];</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Obtain input samples per thread</span></div>
<div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data[4];</div>
<div class="line">    ...</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Compute the block-wide histogram</span></div>
<div class="line">    <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>(temp_storage).Histogram(data, smem_histogram);</div>
</div><!-- fragment --></dd></dl>
<dl class="section user"><dt>Performance and Usage Considerations</dt><dd><ul>
<li>The histogram output can be constructed in shared or global memory</li>
<li>See <a class="el" href="namespacecub.html#a845ca81ef9b346ef7429a35d4fdc80d2" title="BlockHistogramAlgorithm enumerates alternative algorithms for the parallel construction of block-wide...">cub::BlockHistogramAlgorithm</a> for performance details regarding algorithmic alternatives </li>
</ul>
</dd></dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00149">149</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html">TempStorage</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The operations exposed by <a class="el" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">BlockHistogram</a> require a temporary memory allocation of this nested type for thread communication. This opaque storage can be allocated directly using the <code>__shared__</code> keyword. Alternatively, it can be aliased to externally allocated memory (shared or global) or <code>union</code>'d with other storage allocation types to facilitate memory reuse.  <a href="structcub_1_1_block_histogram_1_1_temp_storage.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Methods</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">Collective constructors</div></td></tr>
<tr class="memitem:a60061b56700655655b83a1c5921ae026"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a60061b56700655655b83a1c5921ae026"></a>
__device__ __forceinline__&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026">BlockHistogram</a> ()</td></tr>
<tr class="memdesc:a60061b56700655655b83a1c5921ae026"><td class="mdescLeft">&#160;</td><td class="mdescRight">Collective constructor for 1D thread blocks using a private static allocation of shared memory as temporary storage. Threads are identified using <code>threadIdx.x</code>. <br/></td></tr>
<tr class="separator:a60061b56700655655b83a1c5921ae026"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aceed4d42c6ed10e14a707ab9a35a10c6"><td class="memItemLeft" align="right" valign="top">__device__ __forceinline__&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#aceed4d42c6ed10e14a707ab9a35a10c6">BlockHistogram</a> (<a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html">TempStorage</a> &amp;temp_storage)</td></tr>
<tr class="memdesc:aceed4d42c6ed10e14a707ab9a35a10c6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Collective constructor for 1D thread blocks using the specified memory allocation as temporary storage. Threads are identified using <code>threadIdx.x</code>.  <a href="#aceed4d42c6ed10e14a707ab9a35a10c6">More...</a><br/></td></tr>
<tr class="separator:aceed4d42c6ed10e14a707ab9a35a10c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7ba4e9f53945968ed47227376ea3caa1"><td class="memItemLeft" align="right" valign="top">__device__ __forceinline__&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#a7ba4e9f53945968ed47227376ea3caa1">BlockHistogram</a> (int linear_tid)</td></tr>
<tr class="memdesc:a7ba4e9f53945968ed47227376ea3caa1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Collective constructor using a private static allocation of shared memory as temporary storage. Each thread is identified using the supplied linear thread identifier.  <a href="#a7ba4e9f53945968ed47227376ea3caa1">More...</a><br/></td></tr>
<tr class="separator:a7ba4e9f53945968ed47227376ea3caa1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae87c89f1175ce34f0c60f1cf9719d5f0"><td class="memItemLeft" align="right" valign="top">__device__ __forceinline__&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#ae87c89f1175ce34f0c60f1cf9719d5f0">BlockHistogram</a> (<a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html">TempStorage</a> &amp;temp_storage, int linear_tid)</td></tr>
<tr class="memdesc:ae87c89f1175ce34f0c60f1cf9719d5f0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Collective constructor using the specified memory allocation as temporary storage. Each thread is identified using the supplied linear thread identifier.  <a href="#ae87c89f1175ce34f0c60f1cf9719d5f0">More...</a><br/></td></tr>
<tr class="separator:ae87c89f1175ce34f0c60f1cf9719d5f0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Histogram operations</div></td></tr>
<tr class="memitem:a3cae3cfe2ca8388fb2e3a18c0822db3a"><td class="memTemplParams" colspan="2">template&lt;typename HistoCounter &gt; </td></tr>
<tr class="memitem:a3cae3cfe2ca8388fb2e3a18c0822db3a"><td class="memTemplItemLeft" align="right" valign="top">__device__ __forceinline__ void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#a3cae3cfe2ca8388fb2e3a18c0822db3a">InitHistogram</a> (HistoCounter histogram[BINS])</td></tr>
<tr class="memdesc:a3cae3cfe2ca8388fb2e3a18c0822db3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the shared histogram counters to zero.  <a href="#a3cae3cfe2ca8388fb2e3a18c0822db3a">More...</a><br/></td></tr>
<tr class="separator:a3cae3cfe2ca8388fb2e3a18c0822db3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a53ca73d018639c89b4e0b1ed3e0f67f0"><td class="memTemplParams" colspan="2">template&lt;typename HistoCounter &gt; </td></tr>
<tr class="memitem:a53ca73d018639c89b4e0b1ed3e0f67f0"><td class="memTemplItemLeft" align="right" valign="top">__device__ __forceinline__ void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#a53ca73d018639c89b4e0b1ed3e0f67f0">Histogram</a> (T(&amp;items)[ITEMS_PER_THREAD], HistoCounter histogram[BINS])</td></tr>
<tr class="memdesc:a53ca73d018639c89b4e0b1ed3e0f67f0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a block-wide histogram in shared/global memory. Each thread contributes an array of input elements.  <a href="#a53ca73d018639c89b4e0b1ed3e0f67f0">More...</a><br/></td></tr>
<tr class="separator:a53ca73d018639c89b4e0b1ed3e0f67f0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a86aca800e8a8e886b5d328e7aa3c5582"><td class="memTemplParams" colspan="2">template&lt;typename HistoCounter &gt; </td></tr>
<tr class="memitem:a86aca800e8a8e886b5d328e7aa3c5582"><td class="memTemplItemLeft" align="right" valign="top">__device__ __forceinline__ void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classcub_1_1_block_histogram.html#a86aca800e8a8e886b5d328e7aa3c5582">Composite</a> (T(&amp;items)[ITEMS_PER_THREAD], HistoCounter histogram[BINS])</td></tr>
<tr class="memdesc:a86aca800e8a8e886b5d328e7aa3c5582"><td class="mdescLeft">&#160;</td><td class="mdescRight">Updates an existing block-wide histogram in shared/global memory. Each thread composites an array of input elements.  <a href="#a86aca800e8a8e886b5d328e7aa3c5582">More...</a><br/></td></tr>
<tr class="separator:a86aca800e8a8e886b5d328e7aa3c5582"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="aceed4d42c6ed10e14a707ab9a35a10c6"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T , int BLOCK_THREADS, int ITEMS_PER_THREAD, int BINS, BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">__device__ __forceinline__ <a class="el" href="classcub_1_1_block_histogram.html">cub::BlockHistogram</a>&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;::<a class="el" href="classcub_1_1_block_histogram.html">BlockHistogram</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html">TempStorage</a> &amp;&#160;</td>
          <td class="paramname"><em>temp_storage</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Collective constructor for 1D thread blocks using the specified memory allocation as temporary storage. Threads are identified using <code>threadIdx.x</code>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">temp_storage</td><td>Reference to memory allocation having layout type <a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html" title="The operations exposed by BlockHistogram require a temporary memory allocation of this nested type fo...">TempStorage</a> </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00224">224</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>

</div>
</div>
<a class="anchor" id="a7ba4e9f53945968ed47227376ea3caa1"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T , int BLOCK_THREADS, int ITEMS_PER_THREAD, int BINS, BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">__device__ __forceinline__ <a class="el" href="classcub_1_1_block_histogram.html">cub::BlockHistogram</a>&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;::<a class="el" href="classcub_1_1_block_histogram.html">BlockHistogram</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>linear_tid</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Collective constructor using a private static allocation of shared memory as temporary storage. Each thread is identified using the supplied linear thread identifier. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">linear_tid</td><td>A suitable 1D thread-identifier for the calling thread (e.g., <code>(threadIdx.y * blockDim.x) + linear_tid</code> for 2D thread blocks) </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00235">235</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>

</div>
</div>
<a class="anchor" id="ae87c89f1175ce34f0c60f1cf9719d5f0"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T , int BLOCK_THREADS, int ITEMS_PER_THREAD, int BINS, BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">__device__ __forceinline__ <a class="el" href="classcub_1_1_block_histogram.html">cub::BlockHistogram</a>&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;::<a class="el" href="classcub_1_1_block_histogram.html">BlockHistogram</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html">TempStorage</a> &amp;&#160;</td>
          <td class="paramname"><em>temp_storage</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>linear_tid</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Collective constructor using the specified memory allocation as temporary storage. Each thread is identified using the supplied linear thread identifier. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">temp_storage</td><td>Reference to memory allocation having layout type <a class="el" href="structcub_1_1_block_histogram_1_1_temp_storage.html" title="The operations exposed by BlockHistogram require a temporary memory allocation of this nested type fo...">TempStorage</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">linear_tid</td><td><b>[optional]</b> A suitable 1D thread-identifier for the calling thread (e.g., <code>(threadIdx.y * blockDim.x) + linear_tid</code> for 2D thread blocks) </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00246">246</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a86aca800e8a8e886b5d328e7aa3c5582"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T , int BLOCK_THREADS, int ITEMS_PER_THREAD, int BINS, BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt; </div>
<div class="memtemplate">
template&lt;typename HistoCounter &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">__device__ __forceinline__ void <a class="el" href="classcub_1_1_block_histogram.html">cub::BlockHistogram</a>&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;::Composite </td>
          <td>(</td>
          <td class="paramtype">T(&amp;)&#160;</td>
          <td class="paramname"><em>items</em>[ITEMS_PER_THREAD], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">HistoCounter&#160;</td>
          <td class="paramname"><em>histogram</em>[BINS]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Updates an existing block-wide histogram in shared/global memory. Each thread composites an array of input elements. </p>
<p>A subsequent <code>__syncthreads()</code> threadblock barrier should be invoked after calling this method if the collective's temporary storage (e.g., <code>temp_storage</code>) is to be reused or repurposed.</p>
<p>The code snippet below illustrates a the initialization and update of a histogram of 512 integer samples that are partitioned across 128 threads where each thread owns 4 samples. </p>
<dl class="section user"><dt></dt><dd><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="cub_8cuh.html">cub/cub.cuh</a>&gt;</span></div>
<div class="line"></div>
<div class="line">__global__ <span class="keywordtype">void</span> ExampleKernel(...)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Specialize a 256-bin BlockHistogram type for 128 threads having 4 character samples each</span></div>
<div class="line">    <span class="keyword">typedef</span> <a class="code" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">cub::BlockHistogram&lt;unsigned char, 128, 4, 256&gt;</a> <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for BlockHistogram</span></div>
<div class="line">    __shared__ <span class="keyword">typename</span> BlockHistogram::TempStorage temp_storage;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for block-wide histogram bin counts</span></div>
<div class="line">    __shared__ <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> smem_histogram[256];</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Obtain input samples per thread</span></div>
<div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> thread_samples[4];</div>
<div class="line">    ...</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Initialize the block-wide histogram</span></div>
<div class="line">    <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>(temp_storage).InitHistogram(smem_histogram);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Update the block-wide histogram</span></div>
<div class="line">    <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>(temp_storage).Composite(thread_samples, smem_histogram);</div>
</div><!-- fragment --></dd></dl>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">HistoCounter</td><td><b>[inferred]</b> Histogram counter type </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">items</td><td>Calling thread's input values to histogram </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">histogram</td><td>Reference to shared/global memory histogram </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00403">403</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>

</div>
</div>
<a class="anchor" id="a53ca73d018639c89b4e0b1ed3e0f67f0"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T , int BLOCK_THREADS, int ITEMS_PER_THREAD, int BINS, BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt; </div>
<div class="memtemplate">
template&lt;typename HistoCounter &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">__device__ __forceinline__ void <a class="el" href="classcub_1_1_block_histogram.html">cub::BlockHistogram</a>&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;::Histogram </td>
          <td>(</td>
          <td class="paramtype">T(&amp;)&#160;</td>
          <td class="paramname"><em>items</em>[ITEMS_PER_THREAD], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">HistoCounter&#160;</td>
          <td class="paramname"><em>histogram</em>[BINS]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs a block-wide histogram in shared/global memory. Each thread contributes an array of input elements. </p>
<p>A subsequent <code>__syncthreads()</code> threadblock barrier should be invoked after calling this method if the collective's temporary storage (e.g., <code>temp_storage</code>) is to be reused or repurposed.</p>
<p>The code snippet below illustrates a 256-bin histogram of 512 integer samples that are partitioned across 128 threads where each thread owns 4 samples. </p>
<dl class="section user"><dt></dt><dd><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="cub_8cuh.html">cub/cub.cuh</a>&gt;</span></div>
<div class="line"></div>
<div class="line">__global__ <span class="keywordtype">void</span> ExampleKernel(...)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Specialize a 256-bin BlockHistogram type for 128 threads having 4 character samples each</span></div>
<div class="line">    <span class="keyword">typedef</span> <a class="code" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">cub::BlockHistogram&lt;unsigned char, 128, 4, 256&gt;</a> <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for BlockHistogram</span></div>
<div class="line">    __shared__ <span class="keyword">typename</span> BlockHistogram::TempStorage temp_storage;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for block-wide histogram bin counts</span></div>
<div class="line">    __shared__ <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> smem_histogram[256];</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Obtain input samples per thread</span></div>
<div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> thread_samples[4];</div>
<div class="line">    ...</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Compute the block-wide histogram</span></div>
<div class="line">    <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>(temp_storage).Histogram(thread_samples, smem_histogram);</div>
</div><!-- fragment --></dd></dl>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">HistoCounter</td><td><b>[inferred]</b> Histogram counter type </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">items</td><td>Calling thread's input values to histogram </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">histogram</td><td>Reference to shared/global memory histogram </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00351">351</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>

</div>
</div>
<a class="anchor" id="a3cae3cfe2ca8388fb2e3a18c0822db3a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T , int BLOCK_THREADS, int ITEMS_PER_THREAD, int BINS, BlockHistogramAlgorithm ALGORITHM = BLOCK_HISTO_SORT&gt; </div>
<div class="memtemplate">
template&lt;typename HistoCounter &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">__device__ __forceinline__ void <a class="el" href="classcub_1_1_block_histogram.html">cub::BlockHistogram</a>&lt; T, BLOCK_THREADS, ITEMS_PER_THREAD, BINS, ALGORITHM &gt;::InitHistogram </td>
          <td>(</td>
          <td class="paramtype">HistoCounter&#160;</td>
          <td class="paramname"><em>histogram</em>[BINS])</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Initialize the shared histogram counters to zero. </p>
<p>The code snippet below illustrates a the initialization and update of a histogram of 512 integer samples that are partitioned across 128 threads where each thread owns 4 samples. </p>
<dl class="section user"><dt></dt><dd><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="cub_8cuh.html">cub/cub.cuh</a>&gt;</span></div>
<div class="line"></div>
<div class="line">__global__ <span class="keywordtype">void</span> ExampleKernel(...)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Specialize a 256-bin BlockHistogram type for 128 threads having 4 character samples each</span></div>
<div class="line">    <span class="keyword">typedef</span> <a class="code" href="classcub_1_1_block_histogram.html" title="The BlockHistogram class provides collective methods for constructing block-wide histograms from data...">cub::BlockHistogram&lt;unsigned char, 128, 4, 256&gt;</a> <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for BlockHistogram</span></div>
<div class="line">    __shared__ <span class="keyword">typename</span> BlockHistogram::TempStorage temp_storage;</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Allocate shared memory for block-wide histogram bin counts</span></div>
<div class="line">    __shared__ <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> smem_histogram[256];</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Obtain input samples per thread</span></div>
<div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> thread_samples[4];</div>
<div class="line">    ...</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Initialize the block-wide histogram</span></div>
<div class="line">    <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>(temp_storage).InitHistogram(smem_histogram);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Update the block-wide histogram</span></div>
<div class="line">    <a class="code" href="classcub_1_1_block_histogram.html#a60061b56700655655b83a1c5921ae026" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockHistogram</a>(temp_storage).Composite(thread_samples, smem_histogram);</div>
</div><!-- fragment --></dd></dl>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">HistoCounter</td><td><b>[inferred]</b> Histogram counter type </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="block__histogram_8cuh_source.html#l00298">298</a> of file <a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="block__histogram_8cuh_source.html">block_histogram.cuh</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Aug 23 2013 17:31:11 for CUB by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
<br>
&copy; 2013 NVIDIA Corporation
</small></address>
</body>
</html>
